import util.TreeNode;

/**
 * Created by losor on 2016/9/29.
 */
public class _404_Sum_of_Left {
    public static void main(String[] args) {

    }

    public static int sumOfLeftLeaves(TreeNode root) {
        return sumOfLeftLeaves(root , false);
    }
    public static int sumOfLeftLeaves(TreeNode root , boolean isleft){
        int l = 0 ;
        int r = 0;
        if(root.left == null && root.right == null && isleft){
            return root.val;
        }
        else if(root.left == null && root.right == null){
            return 0;
        }
        else{
            if (root.left != null){
                l = sumOfLeftLeaves(root.left,true);
            }
            if (root.right != null){
                r = sumOfLeftLeaves(root.right,false);
            }
            return l+r;
        }
    }

}
